import 'package:flutter/material.dart';

class LessonPic extends StatelessWidget {
  const LessonPic({Key? key, required this.imgUrl, this.label, this.type, this.imgWidth, this.imgHeight}) : super(key: key);

  final String imgUrl;

  final double? imgWidth;

  final double? imgHeight;

  final String? label;

  final String? type;

  @override
  Widget build(BuildContext context) {
    String? tag = label;
    if (type == 'video') {
      tag = "视频";
    }
    return ClipRRect(
      borderRadius: BorderRadius.circular(5),
      child: Stack(
        children: [
          Image.network(
            imgUrl,
            width: imgWidth,
            height: imgHeight,
            fit: BoxFit.fill,
          ),
          if (tag != null)
            Positioned(
              left: 0,
              bottom: 0,
              child: Container(
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.only(topRight: Radius.circular(5)),
                  gradient: LinearGradient(
                    begin: Alignment.topCenter,
                    end: Alignment.bottomCenter,
                    stops: [0.2, 0.7],
                    colors: [
                      Color.fromARGB(100, 0, 0, 0),
                      Color.fromARGB(100, 0, 0, 0),
                    ],
                  ),
                ),
                alignment: Alignment.center,
                width: 33,
                child: Text(
                  "${tag}",
                  style: TextStyle(color: Colors.white, fontSize: 12),
                ),
              ),
            ),
        ],
      ),
    );
  }
}
